using Microsoft.EntityFrameworkCore;
using Project_Schedule.Configures;
using Project_Schedule.Domain.Receptionist.com.core.Interface;
using Project_Schedule.Domain.Request;
using Project_Schedule.Model;

namespace Project_Schedule.Domain.Receptionist.com.core.Service;

public class System_GetRefuseUserMesService : ISystemGetRefuseUserMessage
{
    public async Task<JRequest> GetRegisterUserMes(string errorCode)
    {
        try
        {
            await using var db = new DataDbContext();
            var info = await db.SystemUsers?.FirstOrDefaultAsync(e =>
                e.ErrorCode == errorCode);
            if (info is null) throw new Exception("错误查询码错误");
            return JRequest.Ok(info);
        }
        catch (Exception exception)
        {
            _logHelper.LogError(exception);
            return JRequest.Ok(false, false, exception.Message);
        }
    }

    private readonly INLogHelper _logHelper;

    public System_GetRefuseUserMesService(INLogHelper logHelper)
    {
        _logHelper = logHelper;
    }
}